﻿using System;
using System.Runtime.Serialization;

namespace Mads.CoreDomain
{
  /// <summary>
  /// Base class for versioned CoreDomain objects.
  /// </summary>
  [DataContract]
  public abstract class VersionedKeyAbstraction : KeyAbstraction
  {
    /// <summary>
    /// Version of the object.
    /// </summary>
    public uint Version { get; set; }

    /// <summary>
    /// Date and time of the object creation.
    /// </summary>
    public DateTime CreatedAt { get; set; }

    /// <summary>
    /// Date and time when object was last modified.
    /// </summary>
    public DateTime ModifiedAt { get; set; }

    /// <summary>
    /// Whether this object is not used anymore.
    /// </summary>
    public bool Obsolete { get; set; }

    public VersionedKeyAbstraction()
    {
      CreatedAt = DateTime.UtcNow;
    }

    public VersionedKeyAbstraction(uint version)
      : this()
    {
      Version = version;
    }
  }
}